<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<div class="white-bg">
	<div align="center">
		<div class="main-content">
			<form id="form-config-add">
				<table class="table table-striped table-bordered table-td">
			        <tbody>
			        	<tr>
		                	<td>
			                	<label class="is-required">参数名称：</label>
			                </td>
			                <td>
		                		<input id="configName" name="configName" class="easyui-textbox" style="width:300px;" data-options="prompt:'请输入参数名称',validType:['length[1,30]']" required="required" type="text">
			                </td>
			            </tr> 
			            <tr>
			                <td>
			                	<label class="is-required">参数键名：</label>
		                	</td>
			                <td>
	                	 		<input id="configKey" name="configKey" class="easyui-textbox" style="width:300px;" data-options="prompt:'请输入参数键名',validType:['length[1,60]'],required:true" type="text">
			                </td>
			            </tr>
			            <tr>
		                	<td>
			                	<label class="is-required">参数键值：</label>
			                </td>
			                <td>
		                		<input id="configValue" name="configValue" class="easyui-textbox" style="width:300px;" data-options="prompt:'请输入参数键值',validType:['length[1,30]'],required:true" type="text">
			                </td>
			            </tr> 
			            <tr>
			                <td>
			                	<label class="is-required">系统内置：</label>
			                </td>
			                <td>
			                	<select name="configType" class="easyui-combobox" style="width: 150px;" data-options="required:true,editable:false,panelHeight:100" th:with="type=${@dict.getType('sys_yes_no')}">
	                    			<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
	                			</select>
			                </td>
		                </tr>
		                <tr>
			                <td>
			                	<label>备注：</label>
		                	</td>
			                <td>
	                	 		<input class="easyui-textbox" name="remark" data-options="prompt:'请输入备注',validType:['maxLength[200]'],multiline:true" style="height:80px;width:300px;">
			                </td>
			            </tr>
				 	</tbody>
			    </table>
			    <div id="dlg-buttons">
			    	<a class="easyui-linkbutton" iconCls="icon-save" onclick="submitHandler()">保存</a>
                    <a class="easyui-linkbutton" iconCls="icon-cancel" onclick="$.easyUIModal.close()">关闭</a>
		    	</div>
		    </form>
		</div>
	</div>
</div>
<script th:inline="javascript">
	$("#configKey").textbox({
		onChange: function (newValue, oldValue) {
			if($.common.trim(newValue) != $.common.trim(oldValue)){
				var url = prefix + "/checkConfigKeyUnique";
				var queryParams = {"configKey" : $.common.trim(newValue)};
				$.easyUIOperate.ajax(url, "post", "json", queryParams, function(result){
					if(!$.validate.unique(result)){
						$("#configKey").textbox("setValue","").textbox("textbox").focus();
						$.messager.show({
							title : '提示',
							msg : "该参数键名已经存在！",
							timeout: 1000
						});
					}
				});
			}
		}
	});
	
	function submitHandler() {
	    	$.easyUIOperate.save(prefix + "/add", $('#form-config-add'));
	}
</script>